local Person = {}
function Person:new(name)
    local obj = {
        name = name
    }
    setmetatable(obj, {
        __index = Person,
        __newindex = function(t, k, v)
            Person[k] = v   -- 给不存在的变量赋值
        end
    })
    return obj
end

function Person:greet()
    print("Hello, " .. self.name)
end

local p = Person:new("Alice")
p:greet()

p.age = 20
print(p.age)
